package org.core.blog.controller;

import lombok.extern.slf4j.Slf4j;
import org.core.blog.pojo.Category;
import org.core.blog.pojo.Result;
import org.core.blog.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/catg")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping
    public Result getList(){
        log.info("获取分类列表");
        List<Category> categories = categoryService.getList();
        return Result.success(categories);
    }
}
